﻿namespace Lilium.CSharp.Expressions.Substitutions

module Patterns =
    
    open System
    open System.Linq.Expressions
    
    open Monad.Maybe
    
    open Lilium.CSharp.Expressions.Patterns
    open Lilium.CSharp.Expressions.Substitutions

    let (|CallSubstitution|_|) providers expr = maybe {
        let! (meth, obj, args) = (|Call|_|) expr
        let! subs = msum (providers |> List.map (fun p -> p.methodCall meth obj args)) 
        return (meth, obj, args, subs) }